package com.itheima.web;

import com.itheima.entry.Result;
import com.itheima.mock.SetmealServiceMock;
import com.itheima.pojo.Setmeal;
import com.itheima.service.SetmealService;
import com.itheima.vo.SetmealVo;
import io.swagger.annotations.Api;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author jshstart
 * @creat 2020-11-16 10:41
 */
@Api
@RestController
@RequestMapping("/h5")
public class SetmealController {

    @Reference(mock = "com.itheima.mock.SetmealServiceMock")
    private SetmealService setmealService;

    @GetMapping("/findAll")
    public List<Setmeal> findAll(){
        return setmealService.findAll();
    }

    @GetMapping("/findAllById/{id}")
    public Setmeal findAllById(@PathVariable("id") Long id){
        return setmealService.findAllById(id);
    }


    @GetMapping("/findAllGroupItem/{id}")
    public Result findAllGroupItem(@PathVariable("id") Long id){
        SetmealVo setmealVo= setmealService.findAllGroupItem(id);
        if (setmealVo==null){
            return new Result(false,"页面火爆，请再次刷新！");
        }
        Result result = new Result(setmealVo);
        return result;
    };
}

